Total Complexity | 5 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import React, { Component, PropTypes } from 'react'; |
||
7 | |||
8 | export class FetchData extends Component { |
||
9 | componentWillMount() { |
||
10 | if (!this.props.isFetched) { |
||
11 | this.fetchData(this.props); |
||
12 | } |
||
13 | } |
||
14 | |||
15 | componentWillReceiveProps(nextProps) { |
||
16 | this.fetchData(nextProps); |
||
17 | } |
||
18 | |||
19 | fetchData(props) { |
||
20 | const promises = grabPromises( |
||
21 | props.components, |
||
22 | props.params, |
||
23 | this.context.store |
||
24 | ); |
||
25 | |||
26 | Promise.all(promises).then(() => { |
||
27 | this.props.actions.doneFetching(); |
||
28 | }); |
||
29 | } |
||
30 | |||
31 | render() { |
||
32 | return <RouterContext {...this.props}/>; |
||
33 | } |
||
62 |